package com.bigegg.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.bigegg.employee.domain.ActivitySignComp;
import com.bigegg.employee.service.IActivitySignCompService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单位签到Controller
 * 
 * @author sun
 * @date 2022-08-16
 */
@RestController
@RequestMapping("/employee/signComp")
public class ActivitySignCompController extends BaseController
{
    @Autowired
    private IActivitySignCompService activitySignCompService;

    /**
     * 查询单位签到列表
     */
    @PreAuthorize("@ss.hasPermi('employee:signComp:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivitySignComp activitySignComp)
    {
        startPage();
        List<ActivitySignComp> list = activitySignCompService.selectActivitySignCompList(activitySignComp);
        return getDataTable(list);
    }

    /**
     * 导出单位签到列表
     */
    @PreAuthorize("@ss.hasPermi('employee:signComp:export')")
    @Log(title = "单位签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivitySignComp activitySignComp)
    {
        List<ActivitySignComp> list = activitySignCompService.selectActivitySignCompList(activitySignComp);
        ExcelUtil<ActivitySignComp> util = new ExcelUtil<ActivitySignComp>(ActivitySignComp.class);
        util.exportExcel(response, list, "单位签到数据");
    }

    /**
     * 获取单位签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:signComp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(activitySignCompService.selectActivitySignCompById(id));
    }

    /**
     * 新增单位签到
     */
    @PreAuthorize("@ss.hasPermi('employee:signComp:add')")
    @Log(title = "单位签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitySignComp activitySignComp)
    {
        return toAjax(activitySignCompService.insertActivitySignComp(activitySignComp));
    }

    /**
     * 修改单位签到
     */
    @PreAuthorize("@ss.hasPermi('employee:signComp:edit')")
    @Log(title = "单位签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivitySignComp activitySignComp)
    {
        return toAjax(activitySignCompService.updateActivitySignComp(activitySignComp));
    }

    /**
     * 删除单位签到
     */
    @PreAuthorize("@ss.hasPermi('employee:signComp:remove')")
    @Log(title = "单位签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activitySignCompService.deleteActivitySignCompByIds(ids));
    }
}
